﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Configuration;
using System.Data.SqlClient;

namespace ViVa.ActiveDirectory
{
    public class Database
    {
        private static string SqlConnectionString()
        {
            return ConfigurationManager.ConnectionStrings["ViVaPortalDatabase"].ConnectionString;
            //return ConfigurationManager.AppSettings["DB_ConnectionString"];
        }

        public static SqlDataReader queryDatabase(string query)
        {
            
            SqlConnection con = new SqlConnection(SqlConnectionString());
            SqlCommand cmd = new SqlCommand(query, con);
            con.Open();
            return cmd.ExecuteReader();
        }

        public static void insertQueryDatabase(string query)
        {
                SqlConnection con = new SqlConnection(SqlConnectionString());
                SqlCommand cmd = new SqlCommand(query, con);
                con.Open();
                cmd.ExecuteNonQuery();
                cmd.Dispose();
        }
    }
}
